package chapter1.No1_4_isAlive方法;

/**
 * 1. isAlive()判断当前的线程是否处于活动状态。（是否执行中）
 *
 * @author liujian
 * @version 2016/11/8 0008
 */
public class MyThread extends Thread {
    public MyThread() {
        System.out.println("构造方法运行开始");
        System.out.println("Thread.currentThread().getName()="+Thread.currentThread().getName());
        System.out.println("Thread.currentThread().isAlive()="+Thread.currentThread().isAlive()); // true
        System.out.println("this.getName()="+this.getName());
        System.out.println("this.isAlive()="+this.isAlive()); // false
        System.out.println("构造方法运行结束");
        System.out.println("=====================================");
    }

    @Override
    public void run() {
        System.out.println("run方法运行开始");
        System.out.println("Thread.currentThread().getName()="+Thread.currentThread().getName());
        System.out.println("Thread.currentThread().isAlive()="+Thread.currentThread().isAlive()); // true
        System.out.println("this.getName()="+this.getName());
        System.out.println("this.isAlive()="+this.isAlive()); // false
        System.out.println("run方法运行结束");
    }

    public static void main(String[] args) {
        MyThread myThread = new MyThread();
        Thread m1 = new Thread(myThread, "A");
        m1.start();
    }
}
